home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Telnet / NCSA / tn3270 2.4d7 source / tn3270 / switcher.c < prev    next >
Text File  |  1992-04-17  |  4KB  |  143 lines

  1. /*
  2.  *  tn3270 for the Macintosh Source Code
  3.  *  Brown University Computing and Information Services
  4.  *  Version 2.4d7  April, 1992
  5.  *  Copyright (c) 1988, 1989, 1990, 1991, 1992 by Brown University and by
  6.  *  Peter John DiCamillo.
  7.  *
  8.  *  Permission is granted to any individual or institution to use, copy,
  9.  *  or redistribute the binary version of this software and its
  10.  *  documentation provided this notice and the copyright notices are
  11.  *  retained.  Permission is granted to any individual or non-profit
  12.  *  institution to use, copy, modify, or redistribute the source files
  13.  *  of this software provided this notice and the copyright notices are
  14.  *  retained.  This software may not be distributed for profit, either
  15.  *  in original form or in derivative works, nor can the source be
  16.  *  distributed to other than an individual or a non-profit institution.
  17.  *  Any  individual or group interested in seeing and/or using these
  18.  *  source files but who are prevented from doing so by the above
  19.  *  constraints should contact Don Wolfe, Assistant Vice-President for
  20.  *  Computer Systems at Brown University, (401) 863-7250, for possible
  21.  *  software licensing of the source developed at Brown.
  22.  *
  23.  *  Brown University and Peter John DiCamillo make no representations
  24.  *  about the suitability of this software for any purpose.
  25.  *
  26.  *  BROWN UNIVERSITY AND PETER JOHN DICAMILLO GIVE NO WARRANTY, EITHER
  27.  *  EXPRESS OR IMPLIED, FOR THE PROGRAM AND/OR DOCUMENTATION PROVIDED,
  28.  *  INCLUDING, WITHOUT LIMITATION, WARRANTY OF MERCHANTABILITY AND
  29.  *  WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE.
  30.  *
  31.  */
  32.  
  33. #if !defined(USEDUMP)
  34.     #include "maclib.h"
  35.     #include "termdef.h"
  36.     #include "tn3270funcs.h"
  37.     #include "globals.h"
  38. #else
  39.     #pragma load "tn3270DumpFile"
  40. #endif
  41.  
  42. GrafPtr suspend_gp;
  43.  
  44. void sw_suspend(long message)
  45. {
  46. WorldTable * wt;
  47. cnr *cp;
  48.  
  49. suspend_gp = FrontWindow();
  50.  
  51. if (!sw_active()) {            /* MultiFinder/System 7 suspend event */
  52.     mf_bgrnd = 1;
  53.     exportscrap(0);
  54.     if (mywindow(suspend_gp, &cp)) justGrowIcon(0, cp);
  55.     if (myxfwindow(suspend_gp, &cp)) xfGrowIcon(cp);
  56.     dfltcurs = 1;
  57.     SetCursor(normcurs);
  58.     return;
  59.     }
  60.  
  61.                             /* Switcher suspend event */
  62. if (message & 0x00000020)    /* convert private to desk scrap if needed */
  63.     exportscrap(0);
  64. sw_bgrnd = 1;             /* indicate backgound mode pending */
  65. sw_upd = 0;                /* reset update flag */
  66. sw_beep = 0;            /* reset beep flag */
  67. wt = get_world();        /* install background routine */    
  68. wt->WTBgtask = (ProcPtr)bgproc; 
  69. }
  70.  
  71. void sw_resume(long message)
  72. {
  73. WorldTable * wt;
  74. cnr * cp;
  75.  
  76. if (message & 0x00000002) importscrap();
  77.  
  78. dfltcurs = 1;
  79. SetCursor(normcurs);
  80.  
  81. if (mf_bgrnd == 1) {
  82.     if (myxfwindow(suspend_gp, &cp)) {
  83.         SelectWindow(suspend_gp);
  84.         xfGrowIcon(cp);
  85.         }
  86.     mf_bgrnd = 0;
  87.     if (mywindow(suspend_gp, &cp)) {
  88.         if (cp->myWindow != 0) {
  89.             if (colormac && (!cp->cs.nocolor)) {
  90.                 ActivatePalette(cp->myWindow);
  91.                 updCTab(cp);
  92.                 newbackcolor(cp);
  93.                 }
  94.             justGrowIcon(0, cp);
  95.             invldscr(cp);
  96.             cp->cs.stat_time += 8;        /* force time to be re-drawn */
  97.             newstat(cp);
  98.             chkpx(cp);
  99.             }
  100.         }
  101.     }
  102. if (sw_bgrnd == 0) return;
  103.  
  104. sw_bgrnd = 0;            /* indcate no longer in background */
  105. wt = get_world();        /* de-install background routine */
  106. wt->WTBgtask = 0;
  107. if (sw_upd) {            /* update for changes during background */
  108.     if (myxfwindow(suspend_gp, &cp)) xfGrowIcon(cp);
  109.     if (mywindow(suspend_gp, &cp)) {
  110.         if (cp->myWindow != 0) {
  111.             justGrowIcon(0, cp);
  112.             invldscr(cp);
  113.             newstat(cp);
  114.             chkpx(cp);
  115.             }
  116.         }
  117.     }
  118. if (sw_beep) beep(cp);
  119. }
  120.  
  121. Boolean sw_active(void)        /* tell caller if we're under Switcher */
  122. {
  123. static long * sw_globals = (long *)0x282;
  124.  
  125. if ((*sw_globals) == 0) return(0);
  126. if ((*sw_globals) == -1) return(0);
  127. return(1);
  128. }
  129.  
  130. WorldTable * get_world(void)
  131. {
  132. static unsigned long * ApplZone = (unsigned long *)0x2aa;
  133.  
  134. return((WorldTable *)((*ApplZone) - 18));
  135. }
  136.  
  137. void sw_proc(void)            /* called as background process */
  138. {
  139. if (haveserial) serevent();
  140. else if (havetcp) tcpevent();
  141. else if (havesa) saevent();
  142. }
  143.